package com.bright.hxj.cwduijie.repository;

import com.bright.hxj.cwduijie.pojo.po.Balance;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface BalanceRepository extends JpaRepository<Balance, Integer>, JpaSpecificationExecutor<Balance> {

    @Query("select ZT_DATA_KEY from Balance where sjjhbz = :sjjhbz group by ZT_DATA_KEY")
    List<String> getDistinctZtDataKeyBySjjhbz(@Param("sjjhbz") int sjjhbz);

    @Query("select SSQJ from Balance where ZT_DATA_KEY=:ztDataKey group by SSQJ")
    List<String> getDistinctSSQJByZtDataKey(@Param("ztDataKey") String ztDataKey);

    @Query("select SSQJ from Balance where ZT_DATA_KEY=:ztDataKey and sjjhbz=:sjjhbz group by SSQJ")
    List<String> getDistinctSSQJByZtDataKeyAndSjjhbz(@Param("ztDataKey") String ztDataKey, @Param("sjjhbz") Integer sjjhbz);

    @Query("from Balance where ZT_DATA_KEY=:ztDataKey and SSQJ=:yearMonth")
    List<Balance> getByZTDATAKEYAndSSQJ(@Param("ztDataKey") String ztDataKey, @Param("yearMonth") String yearMonth);

}